<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<button data="btn">btn1</button>
<button >btn2</button>
<button >btn3</button>
</body>
<script>
    let arr = []
    let btns = document.querySelectorAll('button')

    //filter方法的数组有，但dom节点没有
    console.dir(arr.filter) //ƒ filter()
    console.dir(btns.filter) //undefined

    //使用call 让DOM节点也能使用filter,找出只带data的<button>
    btns = Array.prototype.filter.call(btns,item=>{
        console.log(item)  // <button >btn1</button> <button >btn2</button>  <button >btn3</button>
        return item.hasAttribute('data')
    })
    console.log(btns[0].innerHTML+'带data属性') // btn1带data属性
</script>
</html>